﻿/*
 * Copyright © 2025−2026 WEI.ZHOU (Willis) (Chengdu). All rights reserved.
 *
 * THIS SOURCE CODE IS PROPRIETARY AND CONFIDENTIAL.
 * It is the exclusive property of WEI.ZHOU (Willis) and may not be
 * used, copied, distributed, or disclosed outside of WEI.ZHOU (Willis)
 * without express written permission.
 *
 * This code is provided to WEI.ZHOU (Willis) under a limited, 
 * non-transferable internal license, and is for use only with the author's 
 * approved purposes. No external license is granted or implied.
 *
 * Any unauthorized use, reproduction, or distribution is strictly prohibited
 * and may result in severe civil and criminal penalties.
 */
 
using System.Data;

namespace Aore.Utility.Extensions;

/// <summary>
///  DataTable扩展方法
/// </summary>
public static class DataTableExtensions
{
  /// <summary>
  /// 获取 DataTable 的第一行数据。
  /// </summary>
  /// <param name="table">需要操作的 DataTable。</param>
  /// <returns>DataTable 的第一行数据,如果 DataTable 为空或没有行，则返回 null。</returns>
  public static DataRow FirstRow(this DataTable table)
  {
    if (table == null || table.Rows.Count == 0)
    {
      return null;
    }

    return table.Rows[0];
  }
}